package com.za.wbw.service.wap.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.za.wbw.dao.wap.ProductDao;
import com.za.wbw.model.wap.ProductInfo;
import com.za.wbw.model.wap.vo.ProductDiscountVo;
import com.za.wbw.model.wap.vo.ProductSellVo;
import com.za.wbw.model.wap.vo.ProductVo;
import com.za.wbw.service.wap.ProductService;

public class ProductServiceImpl implements ProductService {
	private ProductDao productDao;
	
	public ProductDao getProductDao() {
		return productDao;
	}
	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
	}
	
	public List<ProductDiscountVo> queryProductDiscountList(int shopId) throws Exception{
		List<ProductInfo> list = this.getProductDao().queryProductDiscountList(shopId);
		List<ProductDiscountVo> vos = new ArrayList<ProductDiscountVo>();
		for (ProductInfo info : list) {
			ProductDiscountVo vo = new ProductDiscountVo();
			vo.setProductId(info.getProductId());
			vo.setProductName(info.getProductName());
			vo.setZoomOut(info.getZoomOut());
			vo.setDealCount(info.getDealCount());
			vo.setSellPrice(info.getSellPrice());
			vo.setDiscountPrice(info.getDiscountPrice());
			vos.add(vo);
		}
		return vos;
	}
	public int queryProductSellCount(int shopId) throws Exception{
		return this.getProductDao().queryProductSellCount(shopId);
	}
	public List<String> queryProductSellList(int shopId) throws Exception{
		return this.getProductDao().queryProductSellList(shopId); 
	}
	public List<ProductSellVo> queryProductSellPage(Map<String, Object> pars) throws Exception{
		List<ProductInfo> list = this.getProductDao().queryProductSellPage(pars);
		List<ProductSellVo> vos = new ArrayList<ProductSellVo>();
		for(ProductInfo info : list){
			ProductSellVo vo = new ProductSellVo();
			vo.setProductId(info.getProductId());
			vo.setProductName(info.getProductName());
			vo.setZoomOut(info.getZoomOut());
			vos.add(vo);
		}
		return vos;
	}
	public ProductVo queryProductInfo(int productId) throws Exception{
		ProductInfo info = this.getProductDao().queryProductInfo(productId);
		ProductVo vo = new ProductVo();
		vo.setProductId(info.getProductId());
		vo.setProductName(info.getProductName());
		vo.setProductBrief(info.getProductBrief());
		vo.setZoomIn(info.getZoomIn());
		vo.setTelephone(info.getTelephone());
		vo.setIsDiscount(info.getIsDiscount());
		vo.setSellPrice(info.getSellPrice());
		vo.setDiscountPrice(info.getDiscountPrice());
		return vo;
	}
}
